package com.wxapp.pay.service.event.listener;

import com.wxapp.common.constant.base.IBaseListen;
import com.wxapp.pay.api.pojo.feign.SaleFeign;
import com.wxapp.pay.api.pojo.pojo.po.vo.pay.QChangeStatusVo;
import com.wxapp.pay.api.pojo.pojo.vo.pay.QPayCallBackVo;
import com.wxapp.pay.service.event.PayCallBackEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author lgl
 */
@Component
@RequiredArgsConstructor
public class PayCallBackListener extends IBaseListen<PayCallBackEvent, QPayCallBackVo> {
    @Qualifier("com.wxapp.pay.api.pojo.feign.SaleFeign")
    private final SaleFeign saleFeign;

    @Override
    protected Object toDealListen(PayCallBackEvent event) throws Exception {
         var data = event.getData();
        QChangeStatusVo vo=new QChangeStatusVo();
        vo.setOrderCode(data.getOrderCode());
        vo.setPayWay(data.getPayWay());
        vo.setNextState("PAID");
        vo.setNowState("UNPAID");
        vo.setPayAccount(vo.getPayAccount());
        vo.setPayTime(data.getPayTime());
        saleFeign.changeStatus(vo);
        return null;
    }
}
